#include <bits/stdc++.h>
using namespace std;

// #define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
	{                                         \
		cerr << "\033[32;1m" << #x << " -> "; \
		err(x);                               \
	}
void err()
{
	cerr << "\033[39;0m" << endl;
}
template <typename T, typename... A>
void err(T a, A... x)
{
	cerr << a << ' ';
	err(x...);
}
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 3005;

int par[N][N], sub[N][N];

vector<int> G[N];

int n, q;

void dfs(int root, int u, int fa)
{
	par[root][u] = fa;
	sub[root][u] = 1;
	for (int v : G[u])
	{
		if (v == fa)
			continue;
		dfs(root, v, u);
		sub[root][u] += sub[root][v];
	}
}

int g[N][N];

void bfs(int s, int dist[])
{
	memset(dist, 0x3f3f3f3f, sizeof(int) * (n + 1));
	dist[s] = 0;
	static int q[N], st, ed;
	st = ed = 0;
	q[ed++] = s;
	while (st < ed)
	{
		int u = q[st++];
		for (int v : G[u])
		{
			if (dist[v] > dist[u] + 1)
			{
				dist[v] = dist[u] + 1;
				q[ed++] = v;
			}
		}
	}
}

typedef pair<int, pair<int, int>> node;
node dat[N * N];

LL dp[N][N];

LL ans[N];

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}

	for (int root = 1; root <= n; ++root)
	{
		dbg(root);
		dfs(root, root, root);
		bfs(root, g[root]);
	}
	int dcnt = 0;
	for (int i=1; i<=n; ++i)
	{
		for (int j=i+1; j<=n; ++j)
		{
			dat[dcnt++] = make_pair(g[i][j], make_pair(i, j));
		}
	}

	sort(dat, dat+dcnt);

	LL Ans = 0;
	for (int i=0; i<dcnt; ++i)
	{
		int u = dat[i].second.first, v = dat[i].second.second;
		dp[v][u] = dp[u][v] = 1LL * sub[u][v] * sub[v][u] + max(dp[par[v][u]][v], dp[u][par[u][v]]);
		ans[dat[i].first] = max(ans[dat[i].first], dp[u][v]);
		Ans = max(Ans, dp[u][v]);
	}

	for (int i=1; i<=n; ++i)
		for (int j=1; j<=n; ++j)
			dbg(i, j, par[i][j], sub[i][j]);

	// LL Ans = 0;
	// for (int i=1; i<=n-1; ++i)
	// {
	// 	Ans = max(Ans, ans[i]);
	// 	dbg(i, ans[i]);
	// 	// Ans += ans[i];
	// }
	printf("%lld\n", Ans);
	// printf("%lld\n", ans[n-1]);

	return 0;
}